//
//  TestURL.h
//  TestMac
//
//  Created by 小星星吃KFC on 2021/6/29.
//

#import <Foundation/Foundation.h>

static void TestURL(void){
    
    
//    NSNumberFormatter* numberFormatter = [[NSNumberFormatteralloc] init];
//
//    [numberFormatter stringFromNumber:A];
    
    
//    NSURLComponents *components =  [NSURLComponents componentsWithString:@"https://www.baidu.com/test?h=1"];
    
    NSURLComponents *components =  [NSURLComponents.alloc initWithURL:[NSURL URLWithString:@"1"] resolvingAgainstBaseURL:NO];;
    
    NSDictionary *params = @{@"name":@"jim",@"age":@(12)};
    
    NSMutableArray<NSURLQueryItem *> *queryItems = NSMutableArray.array;
    [queryItems addObjectsFromArray:components.queryItems];
    
    
    [params enumerateKeysAndObjectsUsingBlock:^(NSString *name, id value, BOOL *stop) {
        value = [value description];
        value = [value stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet];
        NSURLQueryItem *item = [NSURLQueryItem queryItemWithName:name value:value];
        [queryItems addObject:item];
    }];
    
    components.queryItems = queryItems;
    
    NSLog(@"components.URL=%@",components.URL);
    
}
